<!DOCTYPE HTML>
<html>

<head>
   <title> 详情页</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link href="../../../assets/css/dpl-min.css" rel="stylesheet" type="text/css" />
   <link href="../../../assets/css/bui-min.css" rel="stylesheet" type="text/css" />
   <link href="../../../assets/css/page-min.css" rel="stylesheet" type="text/css" />
   <link href="../../../assets/css/jx-style.css" rel="stylesheet" type="text/css" />
   <link href="../../../assets/css/prettify.css" rel="stylesheet" type="text/css" />
</head>

<body>
   <div class="container">
      <div class="detail-page span24">
         <div class="detail-page-title">
            <h4>
               品牌管理
               <button type="button" id="add-new-btn" class=" pull-right jx-btn btn-default">新增品牌</button>
            </h4>
         </div>
         <div class="detail-section">
            <div class="row detail-row">
               <div class="span24">
                  <!-- 表格 start-->
                  <div id="grid"></div>
                  <!-- 表格 end-->
               </div>
            </div>
         </div>
      </div>
   </div>
   <!-- 初始隐藏 dialog内容 -->
   <div id="content" class=" hide ">
      <form class="form-horizontal jx-form">
         <div class="row">
            <div class="control-group span12">
               <label class="control-label">
                        <s>*</s>排序：</label>
               <div class="controls">
                  <input name="a" type="text" data-rules="{required:true,number:true}" class="input-normal control-text">
               </div>
            </div>
         </div>
         <div class="row">
            <div class="control-group span12">
               <label class="control-label">
                        <s>*</s>品牌名称：</label>
               <div class="controls">
                  <input name="b" type="text" data-rules="{required:true}" class="input-large control-text">
               </div>
            </div>
         </div>
         <div class="row">
            <div class="control-group control-row6 span12">
               <label for="" class="control-label has-note">
                    缩略图:
                    <div class="label-note"> 图标尺寸:<br>
                        px*px
                    </div>
                </label>
               <div class="controls">
                  <input id="upload-img" type="file" class="hide">
                  <a href="#" class="btn-upload">
                        <span>上传图片</span>
                        <img src="../../../assets/img/u9486.png" width="98" height="98">
                        <input name="c" type="text" data-rules="{required:true}" value="" style="display: none">
                   </a>
               </div>
            </div>
         </div>
         <div class="row">
            <div class="control-group span12">
               <label class="control-label">
                        品牌编码：</label>
               <div class="controls">
                  <input name="d" type="text"  class="input-normal control-text">
               </div>
            </div>
         </div>

   </div>
   </form>
   </div>
   <script type="text/javascript" src="../../../assets/js/jquery-1.8.1.min.js"></script>
   <script type="text/javascript" src="../../../assets/js/bui-min.js"></script>
   <script type="text/javascript" src="../../../assets/js/config-min.js"></script>
   <script type="text/javascript" src="../../../assets/js/admin.js"></script>
   <script type="text/javascript">
      BUI.use('common/page');
   </script>
   <!-- script start -->
   <script type="text/javascript">
      BUI.use(['bui/grid', 'bui/data', 'common/search'], function (Grid, Data, Search) {
         var Grid = Grid,
            Store = Data.Store,
            columns = [{
               title: '排序',
               dataIndex: 'a',
               elCls: 'center', //居中
               width: 200
            }, {
               title: '缩略图 ',
               elCls: 'center',
               dataIndex: 'b',

               width: 200
            }, {
               title: '品牌名称',
               elCls: 'center',
               dataIndex: 'c',
               width: 200
            }, {
               title: '分类编码',
               elCls: 'center',
               dataIndex: 'd',
               width: 200
            }, {
               title: '商品数',
               elCls: 'center',
               dataIndex: 'e',
               width: 200
            }, {
               title: '操作',
               dataIndex: 'f',
               elCls: 'center',
               width: 200,
               renderer: function (value, obj) {
                  var editStr = '<span class="grid-command btn-edit">[ 编辑 ]</span>';
                  delStr = '<span class="grid-command btn-del">[ 删除 ]</span>'; //页面操作不需要使用Search.createLink
                  return editStr + delStr;
               }
            }],
            data = [{

               a: '1',
               b: '<img src="../../../assets/img/u9486.png">',
               c: 'new balance',
               d: 'hw_001',
               e: '890'

            }];
         //初始化数据
         var isAddRemote = false,
            editing = new Grid.Plugins.DialogEditing({
               contentId: 'content', //设置隐藏的Dialog内容
               triggerCls: 'btn-edit', //触发显示Dialog的样式
               editor: {
                  title: '编辑品牌',
                  width: 600,
               }
            }),
            store = new Store({ //初始化数据
               data: data,
               autoLoad: true, //自动加载数据
               pageSize: 2 // 配置分页数目
            }),
            grid = new Grid.Grid({
               render: '#grid',
               elCls: 'small-bui-grid-table',
               columns: columns,
               loadMask: true, //加载数据时显示屏蔽层
               forceFit: true,

               // 底部工具栏
               bbar: {
                  // pagingBar:表明包含分页栏
                  pagingBar: true
               },
               plugins: [editing], //插件
               store: store
            });

         grid.render();
         //点击操作
         grid.on('itemclick', function (ev) {
            var sender = $(ev.domTarget),
               itemEl = $(ev.element),
               item = ev.item;

            if (sender.hasClass('btn-del')) { //点击删除操作
               delFunction(item, itemEl);

            }
         });
         // 点击添加品牌
         $("#add-new-btn").click(function () {
            addFunction();
         });
         //添加记录
         function addFunction() {
            var newData = {
               b: ''
            };
            editing.add(newData, 'a'); //添加记录后，直接编辑
         }
         //没有多选插件，删除选中的记录
         function delFunction(item, itemEl) {
            BUI.Message.Confirm('确认删除记录？', function () {
               var input = itemEl.find('input'),
                  name = itemEl.attr('name');
               if (name) {
                  form.getField(name).remove();
               }

               store.remove(item);
            }, 'question');
         }
      });
   </script>
   <!-- script end -->

   <body>

</html>